package module;

public class ClientTest {
	
	
	public static void main(String[] arg){
		
		//Below is surface clone
		ProductOrder  order = new ProductOrder();
		
	    order.setOrderName("MyOrderName");
	    order.getUser().setUserName("Flyingyi");
	    order.getUser().setUserId("10000");
	    
	    //clone()---浅拷贝（只是拷贝对象的地址，即：多个对象接指向同一个地址）
	     ProductOrder  surfaceOrder = order.clone();
	    //cloneOrder()--深拷贝(多个对象，每个均有自己对应地址）
	    ProductOrder   deepOrder = (ProductOrder) order.cloneOrder();	  
	    
	    
	    System.out.println("===================================");
	    System.out.println("原对象:"+order.toString());
	    System.out.println("浅拷贝对象:" + surfaceOrder.toString() );  
	    System.out.println("深拷贝对象："+ deepOrder.toString());
	    
	    
	    System.out.println("原有对象发生变化：===================================");
	    order.setOrderName("MyOrderName+++");
	    order.getUser().setUserName("Flyingyi+++");
	    order.getUser().setUserId("10000+++");
	    System.out.println("原对象:"+order.toString());
	    System.out.println("浅拷贝对象:" + surfaceOrder.toString() );  
	    System.out.println("深拷贝对象："+ deepOrder.toString());
	    
	    
        System.out.println("浅拷贝对象发生变化：===================================");
	    
        surfaceOrder.setOrderName("呵呵");
        surfaceOrder.getUser().setUserName("易清林");
        surfaceOrder.getUser().setUserId("888888");
        System.out.println("原对象:"+order.toString());
	    System.out.println("浅拷贝对象:" + surfaceOrder.toString() );  
	    System.out.println("深拷贝对象："+ deepOrder.toString());
	  
		
	}

}
